<html>
<head>
<#import "/common/common.ftl" as netCommon>
<@netCommon.commonStyle />
<title></title>
<@netCommon.commonScript /> <@netCommon.commonLayui /> 
</head>
<body class="layui-layout-body show-scroll-y">
	<div class="layuimini-container">
		<div class="layuimini-main">
			<fieldset class="layui-elem-field layui-field-title" id="searchField">
				<legend>档案管理</legend>
			</fieldset>
			<form class="layui-form" lay-filter="queryForm" id="queryForm">
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md4">
					<div class="layui-form-item">
						<label class="layui-form-label">姓名</label>
						<div class="layui-input-block">
							<input type="text" name="xm" id="xm" placeholder="输入姓名或简拼快速查询"
								class="layui-input" value="" />
						</div>
					</div>
				</div>
				<div class="layui-col-md4">
					<div class="layui-form-item">
						<label class="layui-form-label">所属单位</label>
						<div class="layui-input-block layui-form" lay-filter="ssjgFilter">
							<select name="ssjg" id="ssjg" lay-search="">
							</select>
						</div>
					</div>
				</div>
				<div class="layui-col-md4">
					<div class="layui-form-item">
						<label class="layui-form-label">人员状态</label>
						<div class="layui-input-block layui-form"
							lay-filter="daryztFilter">
							<select name="daryzt" id="daryzt" lay-search="">
							</select>
						</div>
					</div>
				</div>
			</div>
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md4">
					<div class="layui-form-item">
						<label class="layui-form-label">档案状态</label>
						<div class="layui-input-block layui-form"
							lay-filter="dqztFilter">
							<select name="dqzt" id="dqzt" lay-search="">
							</select>
						</div>
					</div>
				</div>
			</div>
			<div class="layui-row">
				<div class="layui-col-xs6">
					<label class="layui-form-label" style="width: 100%;text-align: left;" id="showCount">搜索结果共计0人。</label>
				</div>
				<div class="layui-col-xs6 btn-right">
					<button type="button" class="layui-btn" id="toExport"
							lay-filter="data-export-btn">
							<i class="layui-icon">&#xe67d;</i> 导出结果
					</button>
					<button type="button" class="layui-btn" id="toImport"
							lay-filter="data-import-btn">
							<i class="layui-icon">&#xe67c;</i> 批量导入
					</button>
					<button type="button" class="layui-btn" id="upjpidx"
							lay-filter="data-upjpidx-btn">
							<i class="layui-icon">&#xe669;</i> 更新简拼索引
					</button>
					<button type="button" class="layui-btn" id="toAdd"
							lay-filter="data-add-btn">
							<i class="layui-icon">&#xe624;</i> 新 增
					</button>
					<button type="submit" class="layui-btn" lay-submit
							lay-filter="data-search-btn">
							<i class="layui-icon">&#xe615;</i> 搜 索
					</button>
				</div>
			</div>
				
				<div class="layui-row layui-col-space15">
					<div class="layui-col-md12">
						<div class="layui-card">
							<table id="listData" lay-filter="listData"></table>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>
	<script type="text/javascript" src="${request.contextPath}/static/js/jquery.download.js"></script>
	<script type="text/javascript">
		layui.config({
			base : '${request.contextPath}/static/plugins/cardTable/' //配置 layui 第三方扩展组件存放的基础目录
		}).extend({
			cardTable : 'cardTable'
		});
		layui.use([ 'table', 'form', 'jquery' ], function() {
			let table = layui.table;
			let form = layui.form;
			zdCommon.initZdListOpts("#ssjg", "JGBM", "", true, function() {
				form.render('select', 'ssjgFilter');
			});
			zdCommon.initZdListOpts("#daryzt", "RYZT", "", true, function() {
				form.render('select', 'daryztFilter');
			});
			zdCommon.initZdListOpts("#dqzt", "DAZT", "", true, function() {
				form.render('select', 'dqztFilter');
			});

			//表格数据加载
			var tableList = table.render({
				"elem":"#listData",
				"url":basePath+"/ryda/query",
				"page":true,
				"method":"post",
				"where":fromSerialize("#queryForm"),
				"request":{"pageName":"currentPageNo","limitName":"pageSize"},
				"cols":[[
					{"title":"序号","width":80,"fixed":"left","type":"numbers"},
					{"field":"xm","title":"姓名"},
					{"field":"ssjg","title":"所属单位","templet":function(d){
						return zdCommon.getZdmc("JGBM",d.ssjg,false);
					}},
					{"field":"ssdag","title":"档案位置","templet":function(d){
						return zdCommon.getZdmc("ZWX",d.ssdag,false);
					}},
					{"field":"dqzt","title":"档案状态","templet":function(d){
						return zdCommon.getZdmc("DAZT",d.dqzt,false);
					}},
					{"field":"daryzt","title":"人员状态","templet":function(d){
						return zdCommon.getZdmc("RYZT",d.daryzt,false);
					}},
					{"title":"操作","fixed":"right","width":130,"templet":function(d){
						var tem = [];
						tem.push('<div class="layui-btn-group">');
						tem.push('<button type="button" class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon">&#xe63c;</i>详情</button>');
						tem.push('<button type="button" class="layui-btn layui-btn-xs" lay-event="delete"><i class="layui-icon">&#xe640;</i>删除</button>');
						tem.push('</div">');
						return tem.join('');
					}}
				]],
				"done":function(res, curr, count){
					$("#showCount").html("搜索结果共计"+count+"人。");
				}
			});
			// 监听搜索操作
			form.on('submit(data-search-btn)', function(data) {
				reloadList();
				return false;
			});
			function reloadList(){
				var params = fromSerialize("#queryForm");
				tableList.reload({
					"where":params,
					"page":{
						"currentPageNo":1
					}
				});
			}
			//操作栏
			table.on('tool(listData)', function(obj){
				var rData = obj.data;
				if(obj.event === 'delete'){
					delRydaxx(rData.objectid);
				}else if(obj.event === 'edit'){
					showEdit(rData.objectid);
				}
			});
			$("#toAdd").click(function() {
				showEdit("");
			});
			$("#toImport").click(function(){
				layer.open({
					type : 2,
					title : '人员档案信息-批量导入',
					closeBtn : 1,
					anim : 2,
					offset : '50px',
					area : [ '600px', '250px' ],
					shadeClose : true,
					content : basePath + "/ryda/toImport"
				});
			});
			$("#toExport").click(function(){
				var params = fromSerialize("#queryForm");
				$.download(basePath+"/ryda/exportRydaxx",params,"post");
			});
			$("#upjpidx").click(function(){
				layer.load();
				$.ajax({
					url: basePath+"/ryda/updateXmjp",
					type: "post",
					dataType: "json",
					success: function(data){
						layer.closeAll('loading');
						showMsg.hold(data.msg);
					},
					error:function(){
						layer.closeAll('loading');
					}
				});
			});
			function showEdit(objid) {
				objid = objid == undefined ? "" : objid;
				layer.open({
					type : 2,
					title : '人员档案-编辑',
					closeBtn : 1,
					anim : 2,
					offset : '100px',
					area : [ '700px', '600px' ],
					shadeClose : true,
					content : basePath + "/ryda/edit?objectid=" + objid
				});
			}
			function delRydaxx(objid){
				showMsg.confirm("确定要删除吗？",function(){
					$.ajax({
						url: basePath+"/ryda/delRydaxx?objectid="+objid,
						type: "post",
						dataType: "json",
						success: function(data){
							showMsg.hold(data.msg);
							reloadList();
						}
					});
				});
			}
		});
	</script>
</body>
</html>